from playwright.sync_api import sync_playwright


def login_to_ecommerce_site():
    with sync_playwright() as p:
        browser = p.chromium.launch(headless=False)
        page = browser.new_page()
        page.goto("https://login.taobao.com/member/login.jhtml?spm=a21bo.jianhua/a.754894437.1.5af92a89sD52Ot&f=top&redirectURL=https%3A%2F%2Fwww.taobao.com%2F")  # 替换为实际电商网站登录页面URL


        login_button = page.query_selector('button:has-text("Login")')

        if login_button and login_button.get_attribute('role') == 'button':
            login_button.click()
            print("Login button clicked successfully.")
        else:
            print("Login button not found or does not have the correct role attribute.")

        browser.close()
login_to_ecommerce_site()
